﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PloobsEngine.Light;
using PloobsEngine.Modelo;

namespace PloobsEngine.Loader
{

    public struct ModelInformation
    {
        public string ModelName;
        public string ModelMeshName;        
        public Vector3 scale;
        public Vector3 pos;
        public Quaternion ori;
        public ModelMesh modelMesh;
        public Texture2D difuse;
        public Texture2D normal;
        public Texture2D glow;
        public Texture2D specular;

        public bool HasTexture(TextureType type)
        {
            if (type == TextureType.DIFFUSE)
            {
                return difuse != null;
            }
            else if (type == TextureType.BUMP)
            {
                return normal != null;
            }
            else if (type == TextureType.SPECULAR)
            {
                return specular != null;
            }
            else if (type == TextureType.GLOW)
            {
                return glow != null;
            }
            else if (type == TextureType.PARALAX)
            {
                return false;
            }
            return false;
        }
    }

    public struct CameraInfo
    {
        public Vector3 Position;
        public Vector3 Target;
        public String Name;
    }


    public struct DummyInfo
    {
        public String Name;
        public Vector3 Position;
    }


    public class ModelLoaderData
    {
        List<ModelInformation> modelMeshesInfo = new List<ModelInformation>();
        List<ILight> lightInfo = new List<ILight>();
        List<CameraInfo> cameraInfo = new List<CameraInfo>();
        List<DummyInfo> dummyInfo = new List<DummyInfo>();

        public List<DummyInfo> DummyInfo
        {
            get { return dummyInfo; }
            set { dummyInfo = value; }
        }

        public List<CameraInfo> CameraInfo
        {
            get { return cameraInfo; }
            set { cameraInfo = value; }
        }

        public List<ILight> LightsInfo
        {
            get { return lightInfo; }
            set { lightInfo = value; }
        }

        public List<ModelInformation> ModelMeshesInfo
        {
            get { return modelMeshesInfo; }
            set { modelMeshesInfo = value; }
        }
    }

    public interface IModelLoader
    {                
        /// <summary>
        /// Extract infos about models
        /// </summary>
        /// <param name="name">The name of the File - assume that models is in /Models, textures in /Textures and ModelInfos (when needed) in /ModelInfos</param>
        /// <returns></returns>
        ModelLoaderData Load(string name);
    }
}
